package com.hs.room.provider

import android.content.Context
import com.hs.common.repository.IDeptRepository
import com.hs.common.repository.IRoleRepository
import com.hs.common.repository.IUserRepository
import com.hs.room.AppDatabase
import com.hs.room.repository.ArchiveDictRepository
import com.hs.room.repository.ArchiveRepository
import com.hs.room.repository.DeptRoomRepository
import com.hs.room.repository.DevRepository
import com.hs.room.repository.LogRepository
import com.hs.room.repository.RoleRoomRepository
import com.hs.room.repository.SysLogRepository
import com.hs.room.repository.UserRoomRepository
import com.hs.room.repository.service.IArchiveDictRepository
import com.hs.room.repository.service.IArchiveRepository
import com.hs.room.repository.service.IDevRepository
import com.hs.room.repository.service.ILogRepository
import com.hs.room.repository.service.ISysLogRepository
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
class AppDateBaseModule {

    @Provides
    @Singleton
    fun provideAppDatabase(@ApplicationContext context: Context): AppDatabase {
        return AppDatabase.getInstance(context)
    }

    // 注册DeptRoomRepository
    @Provides
    @Singleton
    fun provideDeptRepository(
        @ApplicationContext context: Context,
        baseAppDatabase: AppDatabase
    ): IDeptRepository {
        return DeptRoomRepository(context, baseAppDatabase)
    }


    // 注册RoleRepository
    @Provides
    @Singleton
    fun provideRoleRepository(
        @ApplicationContext context: Context,
        baseAppDatabase: AppDatabase
    ): IRoleRepository {
        return RoleRoomRepository(context, baseAppDatabase)
    }


    // 注册UserRoomRepository
    @Provides
    @Singleton
    fun provideUserRoomUserRepository(
        @ApplicationContext context: Context,
        baseAppDatabase: AppDatabase
    ): IUserRepository {
        return UserRoomRepository(context, baseAppDatabase)
    }

    @Provides
    @Singleton
    fun provideSysLogRepository(
        @ApplicationContext context: Context,
        baseAppDatabase: AppDatabase
    ): ISysLogRepository {
        return SysLogRepository(context, baseAppDatabase)
    }


    @Provides
    @Singleton
    fun archiveDictRepository(
        @ApplicationContext context: Context,
        baseAppDatabase: AppDatabase
    ): IArchiveDictRepository {
        return ArchiveDictRepository(context, baseAppDatabase)
    }

    @Provides
    @Singleton
    fun archiveRepository(
        @ApplicationContext context: Context,
        baseAppDatabase: AppDatabase
    ): IArchiveRepository {
        return ArchiveRepository(context, baseAppDatabase)
    }

    @Provides
    @Singleton
    fun logRepository(
        @ApplicationContext context: Context,
        baseAppDatabase: AppDatabase
    ): ILogRepository {
        return LogRepository(context, baseAppDatabase)
    }

    @Provides
    @Singleton
    fun devRepository(
        @ApplicationContext context: Context,
        baseAppDatabase: AppDatabase
    ): IDevRepository {
        return DevRepository(context, baseAppDatabase)
    }


}